/*
* INSANE - Interactive Structural Analysis Environment
*
* Copyright (C) 2003-2005
* Universidade Federal de Minas Gerais
* Escola de Engenharia
* Departamento de Engenharia de Estruturas
* 
* Author's email :    insane@dees.ufmg.br
* Author's website :  http://www.dees.ufmg.br/insane
* 
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package br.ufmg.dees.insane.model.disc.element;

import java.util.ArrayList;
import java.util.ListIterator;

import br.ufmg.dees.insane.model.disc.integrationpoint.GaussPoint;
import br.ufmg.dees.insane.model.disc.integrationpoint.IntegrationPoint;
import br.ufmg.dees.insane.model.disc.node.Node;
import br.ufmg.dees.insane.model.disc.parametricintegration.ParametricIntegration;
import br.ufmg.dees.insane.util.IMatrix;
import br.ufmg.dees.insane.util.IPoint3d;

/**
*A class representing a quadrilateral parametric element.<p>
*
*@author Lucas, Marcelo & Pitangueira, Roque
*@version 1.0
*@since June 2004
*/

public abstract class Quadrilateral extends ParametricElement
{
	/** Return the ParametricIntegration object related to the line loads for this Quadrilateral ParametricElement
	*@return  The ParametricIntegration object related to the line loads for this Quadrilateral ParametricElement.
	*/
	public abstract ParametricIntegration getLineEqLoad();
	
	/** Return the ParametricIntegration object related to the volume loads for this Quadrilateral ParametricElement
	*@return  The ParametricIntegration object related to the volume loads for this Quadrilateral ParametricElement.
	*/
	protected abstract ParametricIntegration getAreaEqLoad();
	
	/** Return the ParametricIntegration object related to the volume loads for this Element
	*@return  The ParametricIntegration object related to the volume loads for this Element.
	*/
	protected abstract ParametricIntegration getVolumeEqLoad();
	
	/** Return a ArrayList with PointForces representing the equivalent nodal load.
	*The utility of this method is receive the ParametricIntegration object and select its apropriated integration type method.
	*@return The ArrayList with PointForces representing the equivalent nodal load.
	*/
	protected abstract ArrayList getIntegralValues(ParametricIntegration a);
	
//********************************************************************************	
	/** Generates Gauss Points and theirs Weights factors of this Quadrilateral ParametricElement. 
	*/
	public void generateIntegrationPoints()
	{
		int k = 1;
		integrationPoints.clear();
		for(int i = 0; i < (myIntegrationOrder.getXiIntegOrder()); i++) 
		{
			for(int j = 0; j < (myIntegrationOrder.getEtaIntegOrder()); j++)
			{
				IntegrationPoint ip = new GaussPoint();
				ip.setCoord1((myIntegrationOrder.getXiIntegOrder()-1),i);
				ip.setWeight1((myIntegrationOrder.getXiIntegOrder()-1),i);
				ip.setCoord2((myIntegrationOrder.getEtaIntegOrder()-1),j);
				ip.setWeight2((myIntegrationOrder.getEtaIntegOrder()-1),j);
				ip.setLabel("GP-"+(k));
				integrationPoints.add(ip);
				k++;
			}
		}
	}

//********************************************************************************

	/** Returns the nodal coordinates matrix of this quadrilateral element
	*@return The nodal coordinates matrix.
	*/
	protected IMatrix getNodesCoord()
	{
		Node node;
		IPoint3d nodeCoord;
		int nNos = incidence.size();
		IMatrix cN = new IMatrix(nNos,2);
		
		ListIterator nds = incidence.listIterator();
		int position = 0;
		while (nds.hasNext()) 
		{
			node = (Node) nds.next();
			nodeCoord = node.getCoord();
			
			cN.setElement((position),0,nodeCoord.x);
			cN.setElement((position),1,nodeCoord.y);
			
			position++;
		}
			return(cN);
	}

//********************************************************************************
	
	/** Return the element integration coefficient.
	*@return The thickness of this quadrilateral parametric element 
	*/
	protected double getElmCoefficient()
	{
		return (this.getCrossSection().getThickness());
	}
	
//********************************************************************************
	
	/** Return the inverse of jacobian matrix.
	*@param a The jacobian matrix.
	*@return the inverse of jacobian matrix.
	*/
/*	protected IMatrix invertJacobian(IMatrix a)
	{
		IMatrix b = new IMatrix(2,2);
		b.setZero();
		double detA = (1/(a.determinantLU()));
		b.setElement(0,0,a.getElement(1,1));
		b.setElement(0,1,((-1)*(a.getElement(1,0))));
		b.setElement(1,0,((-1)*(a.getElement(0,1))));
		b.setElement(1,1,a.getElement(0,0));
		
		b.transpose();
		b.setScale((detA));

		return (b);
	}
*/
//********************************************************************************	
	
}
